<?php
	error_reporting(0);
    require_once 'data/handler.php';
//	require_once 'data/addtocart.php'
    /*$session = new SessionControl();
    if(!$session->Check()){
        //unset($_SESSION['allow']);
        unset($_SESSION['fprint']);
        unset($_SESSION['salt_']);
    }*/
    session_start();
    if(!isset($_SESSION["isLoggedIn"]) || !($_SESSION["isLoggedIn"] === true)){
        session_unset();
        session_destroy();
    }
?>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Musique Basse</title>
        <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
        <link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
        <script type="text/javascript" src="js/jquery.min.js"></script>
    </head>
    <body>
        <div id="main" class="page">
            <header>
                <h1><img src="buttons/logo.png"/></h1>
                <h6>A music store for all kinds of music listeners</h6>
                <nav>
                    <a href="index.php"><img src="buttons/home.png"/></a>
                    <a href="products.php"><img src="buttons/products.png"/></a>
                    <!--accessible or shown only to logged in users-->
                    <?php //var_dump($_SESSION);
                        if(!isset($_SESSION["isLoggedIn"]) || !($_SESSION["isLoggedIn"] === true))
                            echo '<a href="login.php" class="fltright"><img src="buttons/login.png"/></a>';
                        else{
                            echo '<a href="account.php"><img src="buttons/account.png"/></a>';
                            if(isAdmin($_SESSION["uname"]))
                                echo ' <a href="admin.php"><img src="buttons/admincp.png"/></a>';
							echo '<a href="cart.php"><img src="buttons/Cart.png"/></a>';
                            echo '<a href="logout.php" class="fltright"><img src="buttons/logout.png"/></a>';
							}
                    ?>
                </nav>
            </header>
            
            <div id="content">
				<div id="feature">
					<div id="products">
						<div id="image">
						<?php
							$id = $_GET['album'];
							getPic($id);
						?>
						</div>
						<div id="tex">
						<?php
							$id = $_GET['album'];
							getProduct($id);
						?>
						</div>
					</div>
				</div>
				<hr/>
                <?php
                    $song = getAlbum($_GET['album']);
					//print_r($song);
                    if(array_key_exists('error', $song))
                        echo 'Error: '.$song['error'].'<br>';
                    else{
                        echo '<table><tr><th>Track No.</th><th>Title</th>';
						echo '<th>Duration</th>';
						//echo '<th><th>';
						echo '<th>Price<th>';
						//echo '<th></th>';
                        for($i = 0; $i < count($song); $i++){
                            echo    '<tr>';
                            echo    '<td align="center" id="td1">'.$song[$i]["trackno"].'</td>';
                            echo    '<td align="center" id="td1">'.$song[$i]["title"].'</td>';
                            echo    '<td align="center" id="td1">'.$song[$i]["duration"].'</td>';
							//echo	'<td><td>';
                            echo    '<td align="center" id="td1" >$'.$song[$i]["price"].'</td>';
							//echo	'<td><td>';
				//	<audio controls="controls">
				//	<source src="Preview/21/Rolling in the Deep.mp3" type="audio/mpeg" /> 
				//	</audio>
							
							echo    '<td><audio controls="controls"><source src="'.$song[$i]["prev"].'" type="audio/mpeg"/></audio></td>';							
							if(!(!isset($_SESSION["isLoggedIn"]) || !($_SESSION["isLoggedIn"] === true))) echo	'<td><a href="addtocart.php?action=add&trackno='.($i+1).'&albumid='.$_GET['album'].'"><img src="buttons/addtocart.png"/></a></td></tr>';
                        }
                        echo '</table>';
                    }
                ?>
            </div>
            
            <div class="clear"></div>
            
            <footer>
                <p>Copyright &copy; 2012 KENNICS. All rights reserved.</p>
                <p>Design by Werdnazner</p>
            </footer>
			<br/><br/><br/>
		</div>
    </body>
</html>
